package com.example.controller;

import com.example.dto.QuestionnaireResponse;
import com.example.dto.ReportResponse;
import com.example.service.DiagnosticService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


@RestController
@RequestMapping("/api/v1/med")
public class DiagnosticController {

    @Autowired
    private DiagnosticService diagnosticService;

    // 请求问卷
    @PostMapping("/diagnose/questionnaire")
    public QuestionnaireResponse getQuestionnaire( @RequestParam String faceImg, @RequestParam String tongueImg) {
        return diagnosticService.getQuestionnaire(faceImg, tongueImg);
    }

    // 提交问卷
    @PostMapping("/questionnaire-answers")
    public void submitQuestionnaire(@Valid @RequestParam String requestId, @RequestParam String mainCorporeity, @RequestBody String[] answers) {
        diagnosticService.submitQuestionnaire(requestId, mainCorporeity, answers);
    }

    // 获取诊断报告
    @GetMapping("/diagnose/report/{requestId}")
    public ReportResponse getReport(@PathVariable String requestId) {
        return diagnosticService.getReport(requestId);
    }

}

